package com.itheima.Demo;

import java.util.Random;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        guess();
    }
    public static void guess() {
        Random r = new Random();
        int number=r.nextInt(100)+1;
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.println("请您输入一个1-100的数字：");
            int guessnum=sc.nextInt();
            if (guessnum>number){
                System.out.println("您输入的数字太大了！");
            }
            else if (guessnum<number){
                System.out.println("您输入的数字太小了！");
            }else {
                System.out.println("恭喜您猜对了！");
                break;
            }
        }
    }
}
